package com.seedwill.common.persistence;

import java.io.Serializable;
import java.util.List;

import com.seedwill.common.model.CompositeObject;
import com.seedwill.common.model.CompositeObjectSchema;
import com.seedwill.common.model.Pair;
import com.seedwill.common.model.SimpleChild;
import com.seedwill.common.model.SimpleObject;
import com.seedwill.common.view.IPagnationView;
import com.seedwill.common.view.ITreeView;

/**
 * 数据操作支持
 * 
 * 
 * @author kdyi
 *
 */
public interface IDataAccssSupport extends IDataQuerySupport {

	/**
	 * 新增
	 * @param entity
	 * @throws DataAccssException
	 */
	public void create(Object entity) throws DataAccssException;
	/**
	 * 新增，返回新增对象的ID
	 * @param entity
	 * @return
	 * @throws DataAccssException
	 */
	public java.io.Serializable createForId(Object entity) throws DataAccssException;
	/**
	 * 新增，返回新增对象
	 * @param entity
	 * @return
	 * @throws DataAccssException
	 */
	public Object createForObject(Object entity) throws DataAccssException;
	/**
	 * 保存
	 * @param entity
	 * @throws DataAccssException
	 */
	public void save(Object entity) throws DataAccssException;
	public void save(Object entity, boolean skipNull) throws DataAccssException;
	/**
	 * 保存
	 * @param entity
	 * @param id
	 * @throws DataAccssException
	 */
	public void save(Object entity, java.io.Serializable id) throws DataAccssException;
	public void save(Object entity, java.io.Serializable id, boolean skipNull) throws DataAccssException;
	/**
	 * 修改
	 * @param entity
	 * @throws DataAccssException
	 */
	public void modify(Object entity) throws DataAccssException;
	public void modify(Object entity, boolean skipNull) throws DataAccssException;
	/**
	 * 修改
	 * @param entity
	 * @return
	 * @throws DataAccssException
	 */
	public java.io.Serializable modifyById(Object entity) throws DataAccssException;
	/**
	 * 修改
	 * @param entity
	 * @return
	 * @throws DataAccssException
	 */
	public Object modifyByObject(Object entity) throws DataAccssException;
	/**
	 * 删除
	 * @param entity
	 * @throws DataAccssException
	 */
	public void delete(Object entity) throws DataAccssException;
	/**
	 * 删除
	 * @param type
	 * @param id
	 * @return
	 * @throws DataAccssException
	 */
	public java.io.Serializable deleteById(String type, java.io.Serializable id) throws DataAccssException;
	/**
	 * 删除
	 * @param type
	 * @param id
	 * @return
	 * @throws DataAccssException
	 */
	public java.io.Serializable deleteById(Class type, java.io.Serializable id) throws DataAccssException;
	/**
	 * 查找
	 * @param type
	 * @param id
	 * @return
	 * @throws DataAccssException
	 */
	public Object findById(Class type, java.io.Serializable id) throws DataAccssException;
	/**
	 * 查找
	 * @param type
	 * @param filter
	 * @return
	 * @throws DataAccssException
	 */
	public Object getSclarObjectByFilter(Class type, Filter... filter) throws DataAccssException;
	/**
	 * 查找
	 * @param type
	 * @param filter
	 * @return
	 * @throws DataAccssException
	 */
	public Object[] getObjectArrayByFilter(Class type, Filter... filter) throws DataAccssException;
	/**
	 * 查找
	 * @param type
	 * @param filter
	 * @return
	 * @throws DataAccssException
	 */
	public int countObjectByFilter(Class type, Filter... filter) throws DataAccssException;
//	/* (non-Javadoc)
//	 * @see com.seedwill.common.persistence.IDataQuerySupport#countObjectByFilter(java.lang.String, com.seedwill.common.persistence.Filter[])
//	 */
//	public int countObjectByFilter(String type, Filter... filter) throws DataAccssException;
	/**
	 * 查找
	 * @param type
	 * @param filter
	 * @return
	 * @throws DataAccssException
	 */
	public List getObjectListByFilter(Class type, Filter... filter) throws DataAccssException;
	/**
	 * 分页查询
	 * @param filterContainer
	 * @return
	 * @throws DataAccssException
	 */
	public IPagnationView getPageByGenericFilter(GenericFilterContainer<?> filterContainer) throws DataAccssException;
	/**
	 * @param entity
	 * @throws DataAccssException
	 */
	public void createEntity(CompositeObject entity) throws DataAccssException;
	/**
	 * @param entity
	 * @throws DataAccssException
	 */
	public void saveEntity(CompositeObject entity) throws DataAccssException;
	/**
	 * @param entity
	 * @throws DataAccssException
	 */
	public void modifyEntity(CompositeObject entity) throws DataAccssException;
//	/**
//	 * @param schema
//	 * @param id
//	 * @return
//	 * @throws DataAccssException
//	 */
//	public CompositeObject findEntity(CompositeObjectSchema schema, java.io.Serializable id)
//			throws DataAccssException;
//	public CompositeObject findEntity(String schemaHint, java.io.Serializable id)
//	throws DataAccssException;
	/**
	 * @param schema
	 * @param id
	 * @throws DataAccssException
	 */
	public void deleteEntity(CompositeObjectSchema schema, java.io.Serializable id)
			throws DataAccssException;
	public void deleteEntity(String schemaType, java.io.Serializable id) throws DataAccssException;
	public void create(Object entity, List<SimpleChild> childrenList) throws DataAccssException;
	
	public void delete(String domainType, Serializable entityId) throws DataAccssException;
	public void delete(String domainType, Serializable entityId, List<SimpleChild> childrenList)
			throws DataAccssException;
	
	public SimpleObject findSimpleById(String domainType, Serializable entityId, List<SimpleChild> childrenList)
			throws DataAccssException;
	
	public boolean isReferRelationEntityExisted(InTransCtx<?> session, String entityType,
			String f1Name, Serializable f1Value, String f2Name, Serializable f2Value)
			throws DataAccssException;
	
	public void update(Object entity, List<SimpleChild> childrenList) throws DataAccssException;

}
